﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Core.Log
{
    class Logger
    {
        object syncObj= new object();
        private static Logger _singleton;

        Queue<ILog> logQueue = new Queue<ILog>();

        public static Logger GetInstance()
        {
            if (_singleton == null)
            {
                _singleton = new Logger();
            }
            return _singleton;
        }

        public void Add(ILog item)
        {
            lock (syncObj)
            {
                logQueue.Enqueue(item);
            }
        }

        public ILog Dequeue()
        {
            lock (syncObj)
            {
                return logQueue.Dequeue();
            }
        }

        public bool HasElements { get { return (logQueue.Count > 0); } }
    }
}
